<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--<link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />-->
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__STATIC__/template/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__STATIC__/template/lib/respond.min.js"></script>

    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/lib/Hui-iconfont/1.0.8/iconfont.css" />

    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="__STATIC__/template/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--/meta 作为公共模版分离出去-->


</head>
<body>
<nav class="breadcrumb">
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">

    <form action="" method="post" class="form form-horizontal" id="form-article-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>所在分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box" style="width:250px;" >
				  <select class="select" id="gt_id" >
                      {foreach name="category" item="v" }
                      <option value="{$v.id}" {$result?($result.gt_id ==$v.id ?'selected = selected':''):''}>{$v.name}</option>
                      {/foreach}
                  </select>
			</span>

            </div>
        </div>

        <!--安卓和苹果区分接口-->
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>接口分类：</label>
            <div class="radio-box">
                <input type="radio" id="radio-2" name="interface" value="1" {$result?($result.interface ==1 ?'checked = checked':''):''}>
                <label for="radio-1">安卓接口</label>
                <input type="radio" id="radio-3" name="interface" value="2" {$result?($result.interface ==2 ?'checked = checked':''):''}>
                <label for="radio-1">iOS接口</label>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>超级券：</label>
            <div class="radio-box">
                <input type="radio" id="radio-1" name="demo-radio1" value="coupon" checked>
                <label for="radio-1">好券清单</label>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>推广位(pid)：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$result.pid?$result.pid:''}" placeholder="	mm_15846965_60100289_12147950487" id="pid" name="pid" style=" width:25%">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>每页数据量：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" class="input-text" value="{$result.page_size?$result.page_size:''}" placeholder="1-100" id="page_size" name="page_size" style=" width:25%">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>采集页数：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$result.page_no?$result.page_no:''}" placeholder="" id="page_no" name="page_no" style=" width:25%">
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                {empty name='result'}
                <button onClick="goods_save_submit();" class="btn btn-primary radius" type="button">
                    <i class="Hui-iconfont">&#xe632;</i> 保存
                </button>
                {else /}
                <input type="hidden" value="{$result.id}" id="coll_id"/>
                <button onClick="goods_edit_submit();" class="btn btn-primary radius" type="button">
                    <i class="Hui-iconfont">&#xe632;</i> 修改
                </button>
                {/empty}
                <button  class="btn btn-default radius" type="reset">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>


<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__STATIC__/template/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__STATIC__/template/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/template/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script>
    /* 采集添加 */
    function goods_save_submit(){

        var gt_id      = $('#gt_id').val();//所在分类
        var name       = $('#gt_id').find("option:selected").text();
        var page_size  = parseInt($('#page_size').val());
        var pid        = $.trim($('#pid').val());
        var page_no    = parseInt($('#page_no').val());
        var goods_interface = 2;
        if($("#radio-2").is(':checked')){
            goods_interface = 1;
        }else{
            goods_interface = 2;
        }
       // alert(interface);
        var url       = "{:url('admin/Collection/coupon_hold')}";
        var data      = {
            gt_id:gt_id,
            name:name,
            page_size:page_size,
            pid:pid,
            page_no:page_no,
            interface:goods_interface
        }
        $.post(url,data,function(res){
            console.log(res);
            if(res.ok){
                layer.msg(res.msg,{icon: 1,time:2000});
                // setTimeout(window.location.href="{:url('goods_list')}",2000);
            }else{
                layer.msg(res.msg,{icon: 5,time:2000});
            }
        })

    }

   /* 修改 */
    function goods_edit_submit(){
        var coll_id      = $('#coll_id').val();
        var gt_id      = $('#gt_id').val();//所在分类
        var name       = $('#gt_id').find("option:selected").text();
        var page_size  = parseInt($('#page_size').val());
        var pid        = $.trim($('#pid').val());
        var page_no    = parseInt($('#page_no').val());
        var goods_interface = 2;
        if($("#radio-2").is(':checked')){
            goods_interface = 1;
        }else{
            goods_interface = 2;
        }
        // alert(interface);
        var url       = "{:url('admin/Collection/coupon_edit')}";
        var data      = {
            coll_id:coll_id,
            gt_id:gt_id,
            name:name,
            page_size:page_size,
            pid:pid,
            page_no:page_no,
            interface:goods_interface
        }
        $.post(url,data,function(res){
            console.log(res);
            if(res.ok){
                layer.msg(res.msg,{icon: 1,time:2000});
                 setTimeout(window.location.href="{:url('coupon_list')}",2000);
            }else{
                layer.msg(res.msg,{icon: 5,time:2000});
            }
        })
    }
</script>
</body>
</html>